import { createRouter, createWebHistory } from 'vue-router'
import Main from '../views/Main.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: '默认路由',
      redirect: "/login",
    },
    {
      path: '/login',
      name: '登录页',
      component: () => import('@/views/Login.vue'),
    },
    {
      path: '/main',
      name: '主页面',
      redirect: "/center",
      component: () => import('@/views/Main.vue'),
      children: [
        {
          path: '/center',
          name: '用户主界面',
          redirect: "/user/itemList",
          component: () => import('@/views/user/Center.vue'),
          children: [
            {
              path: "/user/itemList",
              name: "挑选商品",
              component: () => import('@/views/user/ItemList.vue'),
            },
            {
              path: "/user/cartList",
              name: "购物车",
              component: () => import('@/views/user/CartList.vue'),
            },
            {
              path: "/user/addressList",
              name: "地址信息",
              component: () => import('@/views/user/AddressList.vue'),
            },
            {
              path: "/user/orderList",
              name: "订单信息",
              component: () => import('@/views/user/OrderList.vue'),
            },
            {
              path: "/user/payOrderList",
              name: "支付订单信息",
              component: () => import('@/views/user/PayOrderList.vue'),
            },
            {
              path: "/user/logisticsList",
              name: "物流信息",
              component: () => import('@/views/user/LogisticsList.vue'),
            },
            {
              path: "/user/userInfo",
              name: "用户信息",
              component: () => import('@/views/user/UserInfo.vue'),
            }
          ]
        },
      ],
    },
    {
      path: "/admin",
      name: "管理后台",
      redirect: "/admin/itemList",
      component: () => import('@/views/admin/Admin.vue'),
      children: [
        {
          path: "/admin/itemList",
          name: "商品列表",
          component: () => import('@/views/admin/ItemList.vue'),
        },
        {
          path: "/admin/userList",
          name: "用户列表",
          component: () => import('@/views/admin/UserList.vue'),
        },
        {
          path: "/admin/addressList",
          name: "地址列表",
          component: () => import('@/views/admin/AddressList.vue'),
        },
        {
          path: "/admin/orderList",
          name: "订单列表",
          component: () => import('@/views/admin/OrderList.vue'),
        },
        {
          path: "/admin/payOrderList",
          name: "支付订单列表",
          component: () => import('@/views/admin/PayOrderList.vue'),
        },
        {
          path: "/admin/logisticsList",
          name: "物流信息列表",
          component: () => import('@/views/admin/LogisticsList.vue'),
        },
      ]
    },
  ],
})

export default router
